<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改道路设置')"/>
    <th:block th:include="include :: select2-css"/>
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-road-edit" th:object="${road}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">道路名称：</label>
            <div class="col-sm-8">
                <input name="name" th:field="*{name}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属地区：</label>
            <div class="col-sm-8">
                <input name="region" th:field="*{region}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属用户：</label>
            <div class="col-sm-8">
                <select id="user" name="userId" class="form-control select2-multiple">
                    <option></option>
                    <option th:each="user:${users}" th:value="${user.userId}"
                            th:text="${user.userName}"
                            th:selected="${user.Roadflag}"
                            th:disabled="${user.status == '1'}"></option>
                </select>
                <input type="hidden" name="userName" id="userName">
            </div>
        </div>

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script type="text/javascript">
    var prefix = ctx + "road/road";
    $("#form-road-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $("#userName").val($.form.selectSelectsText("user"));
            $.operate.save(prefix + "/edit", $('#form-road-edit').serialize());
        }
    }

    $(function () {
        $('#user').select2({
            placeholder: "暂时不指定",
            allowClear: true
        });
    })
</script>
</body>
</html>